home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / embedded / mcu11 / examples.arc / EX3 < prev    next >
Text File  |  1988-11-29  |  3KB  |  56 lines

  1. ***********************************************************************
  2. * Example 3-1                                       ~ 65 bytes total  *
  3. *                                                                     *
  4. *  This example program uses the hardware setup in figure 3-1 in test *
  5. * mode.  After reset the CONFIG register is checked against port E.   *
  6. * If it is different, CONFIG is erased and reprogrammed to the port E *
  7. * value.  $30 is written to port A and the program ends.              *
  8. ***********************************************************************
  9.  
  10.        ORG   $A000      Start of external EPROM
  11.  
  12. EX31A  LDS   #$00FF     Establish top of stack
  13.        BSR   DLY10      Allow charge pump to stabilize
  14.        LDAA  $100A      Read port E DIP switches
  15.        ANDA  $#0F       Mask off upper 4 bits (not implimented on 'A8)
  16.        CMPA  $103F      See if CONFIG is same
  17.        BNE   NOWOK      If already OK
  18. * Not OK so first erase CONFIG
  19.        LDAB  #$06       Bulk Erase, and EELAT on
  20.        STAB  $103B      Write to PPROG register
  21.        STAA  $103F      Write to CONFIG address (any data)
  22.        INCB             To $07 - turns on EEPGM bit
  23.        STAB  $103B      Write to PPROG register
  24.        BSR   DLY10      Delay 10 mS for erase to complete
  25.        CLR   $103B      Turn off charge pump (EEPGM to 0)
  26. * Now reprogram CONFIG with data from port E (still in A-reg)
  27.        LDAB  #$02       Turn on EELAT
  28.        STAB  $103B      Write to PPROG register
  29.        STAA  $103F      Write port E data to CONFIG address
  30.        INCB             To $03 - Turns on EEPGM bit
  31.        STAB  $103B      Write to PPROG register
  32.        BSR   DLY10      Delay 10 mS for erase to complete
  33.        CLR   $103B      Turn off charge pump (EEPGM to 0)
  34. * Programming complete but you can't check results till next reset
  35. NOWOK  LDA   #$30
  36.        STAA  $1000      You are done (check with scope)
  37.        BRA   *          Branch to self (hangs till pwr off or rst)
  38. *
  39. *  PROGRAM END     subroutines follow
  40. *
  41. ***
  42. * DLY10 - Subroutine to delay 10mS (for E=2MHz)
  43. ***
  44. DLY10  PSHX             Save X (not required in this ex I just do)
  45.        LDX   #$0D06     3334 * 6~ * 500nS/~ = 10mS
  46. DLOOP  DEX              [3] # in []s is cycles for that instruc
  47.        BNE   DLOOP      [3] cont. for 3334 times (loop time = 6~)
  48.        PULX             Recover X value
  49.        RTS              ** RETURN **
  50. *
  51. *  Establish a reset vector
  52. *
  53.        ORG   $BFFE
  54. RESET  FDB   $A000      Point to start of program
  55.  
  56.